import {countNotice} from "@/api/system/notice";

let timer = null;
let count;


// 获取公告数量
function getData(){
  countNotice().then(response => {
    count = response.data.count
  }).catch(function(err) {
    console.error("获取公告数量失败" ,err);
    clearInterval(timer)
  });
}

export function getMassageCount(){
  if (timer != null) {
    clearInterval(timer);
  }
  setTimeout(() => {
    getData();
    // 每分钟刷新一次
    timer = setInterval(getData, 60000)
  },0)
}

export function getCount(){
  return count;
}
